<?php
/**
 * @Desc 提现管理
 * @Auth jian
 * @Date 2016年3月8日9:17:10
 */
namespace Act\Finance;
use Act\Base;
use App\Lib\Page;
class Cashing extends Base {
	public function doGet() {
		$search = [
			'business_id' => get('business_id', '', 'trim'),
			'business_name' => get('business_name', '', 'strip_tags,trim'),
			'wd_flow_no' => get('wd_flow_no', '', 'strip_tags,trim'),
			'startTime' => get('startTime', '', 'trim'),
			'endTime' => get('endTime', '', 'trim'),
			'status' => get('status', ''),
		];
		$where = 'id > 0';
		if(!empty($search['business_id'])) $where .= " and business_id = {$search['business_id']} ";
		if(!empty($search['business_name'])) $where .= " and business_name like '{$search['business_name']}%' ";
		if(!empty($search['wd_flow_no'])) $where .= " and wd_flow_no = '{$search['wd_flow_no']}' ";
		if(is_numeric($search['status'])) $where .= " and status = {$search['status']} ";
		if(!empty($search['startTime']) && !empty($search['endTime'])) {
			$startTime = strtotime($search['startTime']);
			$endTime = (strtotime($search['endTime'])+86400);
			$where .= " and apply_time >= {$startTime} and apply_time < {$endTime} ";
		}
		// 分页
		$withdraw = model('Withdraw');
		$count = $withdraw->searchCount($where);
		$page = new Page(100, 12);
		$fields = 'id,wd_flow_no,business_name,wd_money,apply_time,status';
		$data = $withdraw->search($where, $page->offset,$page->size, $fields);
		$this->setTemplateNav('提现管理');
		$this->display('cashing.php',[
			'cashing' => $data,
			'search'=>$search,
			'page_html' => $page->show(),
			'page' => $this->getTemplatePageBtns(5,5)
			]);
	}
}